/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import model.Lid;

/**
 *
 * @author Johan
 */
public class MijnDryvesController extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        String address;

        HttpSession sessie = request.getSession();

        // Hier volgt de 5 bovenknoppen active array, in gebruik in include/top_nav.jsp
        Boolean[] topNavActive = new Boolean[]{
            false, false, true, false, false};
        request.setAttribute("topNavActive", topNavActive);

// is user ingelogd?
        if (null == sessie.getAttribute("currentUser")) {
// User IS NOT logged in....  
            
            System.out.println("User is niet ingelogd - Redir naar teaser pagina");
            address = "mijnTeaser.jsp";

        } else {
// User IS logged in....

            //huidige lid uit de sessie halen
            Lid Currentlid = (Lid) sessie.getAttribute("currentUser");

            switch (Currentlid.getRolId()) {
                case 2:
                    address = "mijnDryves.jsp";
                    break;
                case 3:
                    address = "AdvertentieOverzicht";//"mijnAdverteer.jsp";
                    break;
                case 4:
                    address = "mijnBeheer.jsp";
                    break;
                case 5:
                    address = "mijnBeheer.jsp";
                    break;
                default:
                    address = "mijnTeaser.jsp";
            }
        }

        RequestDispatcher dispatcher = request.getRequestDispatcher(address);
        dispatcher.forward(request, response);
    }
}

